class Solution {
    //轮转数组
    public static String   rotate(int[] nums, int k) {
        if (nums.length % 2 != 0) {
            int left = 0;
            int ret=0;

            int right = nums.length - 1;
            for (int i = 0; i < nums.length; i++) {
                ret++;
                if (ret==(left + right) / 2) {
                    left=ret;
                    for (int j = 0; j < k + 1; j++) {
                        int tmp = nums[left];
                        nums[left] = nums[right];
                        nums[right] = tmp;
                        right--;
                        left--;
                    }

                }
            }
        }
        if (nums.length % 2 == 0) {
            int left = 0;
            int ret=0;
            int right = nums.length - 1;
            for (int i = 0; i < nums.length; i++) {

                if (ret== (left + right) / 2) {
                    left=ret;
                    for (int j = 0; j < k; j++) {
                        int tmp = nums[left];
                        nums[left] = nums[right];
                        nums[right] = tmp;
                        right--;
                        left--;
                    }

                }
            }
        }
        return nums.toString();

    }


    public static void main(String[] args) {
        int []array={1,2,3,4,5,6,7};
        rotate(array,3);
        System.out.println(array);
    }
}